import React from 'react'
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom'
import Home from '../views/Home/Home.jsx'
import Login from '../views/Login/Login.jsx'
import Error from '../views/404/Error.jsx'

const Regist = React.lazy(() => import('../views/Regist/Regist.jsx'))

export default function RootRouter() {
    return (
        <React.Suspense fallback={<h1>加载中...</h1>}>
            <HashRouter>
                <Switch>
                    <Redirect exact from='/' to='/home'></Redirect>
                    <Route path='/home' component={Home}></Route>
                    <Route path='/login' component={Login}></Route>
                    <Route path='/regist' component={Regist}></Route>
                    <Route path='/404' component={Error}></Route>
                    <Redirect from='*' to='/404'></Redirect>
                </Switch>
            </HashRouter>
        </React.Suspense>
    )
}
